<?php

namespace App\Model\Admin;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

class Article extends Model
{
    //
	  protected $table = 'article';
    protected $primaryKey = 'art_id';
    public $timestamps = false;
    protected $guarded = [];

    public function upload($file){
    	$path = $file->getRealPath();
    	//获取扩展名
        $ext = $file->getClientOriginalExtension();
    	//echo $ext;
    	$filename = date('YmdHis').uniqid().".".$ext;	
    	//echo $filename;die;
    	$bool = Storage::disk('uploads')->put($filename,file_get_contents($path));
    	if($bool){
    		$data['art_thumb'] ='/storage/app/uploads/'.$filename;
    	}
    	return $data;
    }
}
